package org.jeecg.modules.achachievementstandard.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.achachievementstandard.entity.AchAchievementStandard;
import org.jeecg.modules.achachievementstandard.mapper.AchAchievementStandardMapper;
import org.jeecg.modules.achachievementstandard.service.IAchAchievementStandardService;
import org.jeecg.modules.achachievementstandard.vo.AchAchievementStandardVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Description: ach_achievement_standard
 * @author: baochangrong
 * @Date: 2022-03-16
 * @Version: V1.0
 */
@Service
public class AchAchievementStandardServiceImpl extends ServiceImpl<AchAchievementStandardMapper, AchAchievementStandard> implements IAchAchievementStandardService {

    @Autowired
    AchAchievementStandardMapper achAchievementStandardMapper;

    @Override
    /** vo全部查询 附带关联字段名称 */
    public IPage<AchAchievementStandardVo> getVoAll(Page<AchAchievementStandardVo> page, @Param("achAchievementStandardVo") AchAchievementStandardVo achAchievementStandardVo) {
        List<AchAchievementStandardVo> achAchievementStandardVoList = achAchievementStandardMapper.getVoAll(page, achAchievementStandardVo);
        return page.setRecords(achAchievementStandardVoList);
    }

    @Override
    public List<AchAchievementStandard> queryAllByRelObjId(List<String> ids) {
        LambdaQueryWrapper<AchAchievementStandard> queryWrapper =
                new LambdaQueryWrapper<AchAchievementStandard>().in(AchAchievementStandard::getId, ids)
                        .eq(AchAchievementStandard::getDelFlag, 0)
                        .select(AchAchievementStandard.class, info -> !info.getColumn().equals("id"));
        return list(queryWrapper);
    }

}
